import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
import { WeaAuth } from 'ecCom';

import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;

@inject('carManagerStore')
@observer
export default class CreateShareScope extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    const { carManagerStore } = this.props;
    const { showShare, shareFields, selectId } = toJS(carManagerStore.status);

    return (
      <WeaAuth
        ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@fs24jr`}
        icon="icon-coms-car"
        iconBgcolor="#1A57A0"
        title={getLabel(611, '添加') + getLabel(82752, '共享范围')}
        visible={showShare}
        conditions={shareFields}
        onOk={(datas) => {
          carManagerStore.saveShare({ id: selectId, ...datas });
        }}
        onCancel={() => {
          carManagerStore.setState({ showShare: false });
        }}
      />
    );
  }
}
